package com.hqyj.jinenlai;

import com.hqyj.common.pojo.TestPaper;
import com.hqyj.common.service.ITestPaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.GsonBuilderUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * YanGG
 *
 * @ClassName: jinenlaiController
 * @author: yanguangzhi
 * @date: 2021/10/20 17:02
 */
@RestController
@RequestMapping("exam")
public class jinenlaiController {
    //注入
    @Autowired
    ITestPaperService testPaperServie;

    //查询所有考试
    @RequestMapping("getAllExam")
    private HashMap<String,Object> getAllExam(TestPaper testPaper){
        HashMap<String,Object> map=testPaperServie.queryAllExam(testPaper);
        System.out.println(testPaper.getRow()+" "+testPaper.getPage()+"-----getRow----getPage-------");
        List<TestPaper> list= new ArrayList<>();
        list = (List<TestPaper>) map.get("list");
        for (TestPaper paper : list) {
            System.out.println(paper.toString()+"888888888888888888");
        }
        System.out.println(map.get("total")+"-----------"+map.get("prePage")+"---"+map.get("nextPage"));
        return map;
    }
    //添加考试
    @RequestMapping("addTestPaper")
    private HashMap<String,Object> addExam(TestPaper testPaper){
        System.out.println("----------addTestPaper----------");
        HashMap<String,Object> map = new HashMap<>();
        return testPaperServie.addExam(testPaper);
    }
    //删除考试
    @RequestMapping("deleTestPaper")
    private HashMap<String,Object> deleteTestPaper(Integer id){
        System.out.println("----------deleTestPaper----------");
        return testPaperServie.deleteTestPapper(id);
    }
    //修改考试
    @RequestMapping("updataTestPaper")
    private HashMap<String,Object> updataTestPaper(TestPaper testPaper){
        System.out.println("------------updataTestPaper------------");
        return testPaperServie.updataTestPapper(testPaper);
    }
}
